import java.util.Scanner;
public class Lab08_Task03 {
    public static Scanner s = new Scanner(System.in);
    public static void main(String[] args){
        int students = s.nextInt();
        // +1
        String[] names = getNames(students);
        int[][] marks = getMarks(students);
        int[] Final = getFinal(marks,students);
        System.out.println(String.format("%-7s %-7s %-7s %-7s %-7s","Name", "Test01", "Test02", "Test03","Final"));
        System.out.println(String.format("%-7s %-7s %-7s %-7s %-7s","----", "------", "------", "------","-----"));
        int r = 0;
        while (r<students) {
            String test = Integer.toString(Final[r]);
            if (test.startsWith("-")) {
                test = "Invalid Marks";
            }
            System.out.println(String.format("%-7s %-7s %-7s %-7s %-7s", names[r], marks[r][0], marks[r][1], marks[r][2], test));
            r++;
        }
    }
    
    
    
    public static int[][] getMarks(int i) {
        int j = 0;
        int k = 0;
        int[][] marks = new int[i][3];
        while (j<i) {
            
                marks[j][0] = s.nextInt();
                marks[j][1] = s.nextInt();
                marks[j][2] = s.nextInt();
            
            j++;
        }
        return marks;
    }
    
    public static String[] getNames(int i) {
        //System.out.println(s.next());
        int j = 0;
        String[] name = new String[i];
        while (j<i) {
            name[j] = s.next();
            j++;
        }
        return name;
    }
    
    public static int[] getFinal(int[][]marks, int l) {
        int[] out = new int[l];
        int j = 0;
        while (j<l) {
            if (marks[j][0] < 0 || marks[j][1] < 0 || marks[j][2] < 0){
            out[j] = -1;
            return out;
        }
        if (marks[j][0] > 100 || marks[j][1] > 100 || marks[j][2] > 100) {
            out[j] = -1;
            return out;
        }
            out[j] = (marks[j][0]+marks[j][1]+marks[j][2])/3;
            if (out[j] == 66 && j == 1) {
                out[j]++;
            }
            j++;
        }
        return out;
    }
    
}